﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace DeepTalkDBSerice
{
    /// <summary>
    /// Interface for a rendering service to use. Includes the callback that notifies a render service that there is something
    /// ready for it to render.
    /// </summary>
    [ServiceContract(SessionMode=SessionMode.Required, CallbackContract=typeof(IDTRenderCallback))]
    public interface IDTRender
    {
        /// <summary>
        /// Called when the client is ready to do more work. Must be called
        /// each time when a rendering is done.
        /// </summary>
        [OperationContract(IsOneWay=true)]
        void ReadyForWork();

        /// <summary>
        /// Call when a rendering is done. Calling this does not make the client ready to
        /// receive a new talk to process. ReadyForWork must be called again.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="megaBytesOnDisk"></param>
        [OperationContract]
        void RenderDone(int id, float megaBytesOnDisk, int numberOfTalks);

        /// <summary>
        /// Call to tell the systme that this conference should be re-rendered sometime
        /// in the future. By default the conference will not be re-rendered.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="whenToScan"></param>
        [OperationContract]
        void NextUpdateTime(int id, DateTime whenToScan);

        /// <summary>
        /// Call to tell the system not to bother updating if another update was scheduled.
        /// </summary>
        /// <param name="id"></param>
        [OperationContract]
        void NoFurtherUpdates(int id);

        /// <summary>
        /// Used to update the database with new values for title and
        /// start time.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="title"></param>
        /// <param name="startTime"></param>
        [OperationContract]
        void UpdateConferenceData(int id, string title, DateTime startTime, DateTime endTime);
    }

    /// <summary>
    /// Callback for 
    /// </summary>
    public interface IDTRenderCallback
    {
        [OperationContract]
        bool RenderTalk (DTRenderTalkInfo info);
    }

    /// <summary>
    /// Basic info fed to a rendering app
    /// </summary>
    [DataContract]
    public class DTRenderTalkInfo
    {
        /// <summary>
        /// Can be reconstituted to form an agenda object that
        /// will give access to the conference.
        /// </summary>
        [DataMember]
        public string AgendaXML;

        /// <summary>
        /// The ID entry in the database. Unique, and used to reference
        /// just about everything in the future.
        /// </summary>
        [DataMember]
        public int ID;
    }
}
